<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%
    request.setCharacterEncoding("UTF-8");
    String htmlData = request.getParameter("content1") != null ? request.getParameter("content1") : "";
%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="/WEB-INF/JSP/backHome/modalWindows/StudentsListExamSubject.jsp" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <script type="text/javascript" src="<%=path%>/My97DatePicker/WdatePicker.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=path%>/CSS/backLayout.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/CSS/bombBox.css">
</head>
<style>
    select {
        width: 234px;
        height: 31px
    }

    .gn_name {
        padding-top: 5px
    }

    .div_zilei {
        width: 100%;
        height: 30px
    }

    .tr {
        height: 40px;
        background: #57a0ff;
        font-weight:700;
    }

    .tr td {
        font-size: 14px;
        color: #ffffff
    }

    .tr_td {
        height: 40px;
    }

    .tr_td td {
        border-bottom: 1px solid #ededed;
        text-align: center;
    }

    tr td:nth-child(1) {
        font-size: 14px;
        color: #cccccc
    }

    .date {
        border: 0;
        background: #ffffff;
        text-align: center;
    }

    .tr_td td:nth-child(1) {
        border-left: 1px solid #cccccc;
    }

    .tr_td td:nth-child(3) {
        border-right: 1px solid #cccccc;
    }

    .addTable.deleteTable:HOVER {
        cursor: pointer;
    }

    type[type='checkbox'] {
        width: 15px
    }
    .addSubscribeStudent{
        background-color: #57a0ff;
        height: 35px;
        width: 130px;
        color: #ffffff;
        border: 0;
        margin-top: 20px;
        border-radius: 15px;
        padding: 5px;
        -moz-border-radius: 5px;
        outline: none;
        margin-right: 50px;
        cursor:pointer;
    }
    .div_input_hang {
        width: 100%;
        height: 40px;
    }
    .input_hang {
        float: left;
        width: 500px;
        height: 40px;
    }
</style>
<body style="background: #f5f5f5">
<div class="main">
    <div id="modal-overlay">

    </div>
    <div class="weizhi">
        考试管理>>科目一考试登记>>新增
    </div>
    <div class="div_body" style="box-shadow: 0 0 5px #cccccc;height: 1000px">

        <div class="div_form">
            <form action="<%=path%>/DrivingSys/addSubjectOneReg" method="post" class="form" onsubmit="return subForm()">
                <div class="div_input_hang">
                    <div class="input_hang">
                        <span class="gn_name">驾校&nbsp;:&nbsp;</span>
                        <input type="text" name="name" value="${department.fnameL2}" readonly="readonly" style="color: gray;"/>
                    </div>
                    <div class="input_hang">
                        <span class="gn_name">单据编号&nbsp;:&nbsp;</span>
                        <input type="text" name="fnumber" value="${fnumber}" style="color: gray;" readonly="readonly"/>
                    </div>
                    <div class="input_hang ywrq">
                        <span class="gn_name">考试日期&nbsp;:&nbsp;</span>
                        <input type="text" name="fbizdate" id="ywrq"  value="${time}"
                               onclick="WdatePicker({el:'ywrq',dateFmt:'yyyy-MM-dd'})" onchange="changeFbizdate($(this))"/>
                          <input type="hidden" id="subjectType" value="2">
                        <img onclick="WdatePicker({el:'ywrq',dateFmt:'yyyy-MM-dd'})"
                             src="<%=path%>/image/date.jpg" align="absmiddle" style="padding-left: 15px">
                    </div>
                </div>
                <div class="div_input_hang">
                    <div class="input_hang">
                        <span class="gn_name">参考信息&nbsp;:&nbsp;</span>
                        <input name="fdescription"/>
                    </div>
                    <div class="input_hang">
                        <span class="gn_name">单据状态&nbsp;:&nbsp;</span>
                        <select name="cfbillstate" >
                            <option style="color: gray;" value="3">新增</option>
                        </select>
                    </div>
                    <div class="input_hang">
                        <span class="gn_name">车型&nbsp;:&nbsp;</span>
                        <select class="cfcartype" name="cfcartype" onchange="changeCartype()">
                        	<option value="A1">A1</option>
                        	<option value="A2">A2</option>
                        	<option value="A3">A3</option>
                        	<option value="B1">B1</option>
                        	<option value="B2">B2</option>
                        	<option value="C1" selected="selected">C1</option>
                        	<option value="C2">C2</option>
                        	<option value="C3">C3</option>
                        	<option value="C4">C4</option>
                        	<option value="D">D</option>
                        	<option value="E">E</option>
                        	<option value="F">F</option>
                        	<option value="M">M</option>
                        	<option value="N">N</option>                       	
                        	<option value="P">P</option>
                        </select>
                        
                    </div>
                </div>
                <div class="div_input_hang">
                    <div class="input_hang">
                        <span class="gn_name">指标人数&nbsp;:&nbsp;</span>
                        <input id="cfzbs" name="cfzbs" value="" readonly="readonly"/>
                    </div>
                    <div class="input_hang">
                        <span class="gn_name">当前报考人数&nbsp;:&nbsp;</span>
                        <input id="cfdqbkrs" name="cfdqbkrs" value="0" readonly="readonly"/>
                    </div>               
                </div>
                <div style="margin-left: 90px;">确认报考学员&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="addSubscribeStudent"  value="添加预约学员" /></div>
                <div class="div_zilei">
                    <div style="width: 93%;text-align: right;">
                        <img src="<%=path%>/image/insert2323.jpg" class="addTable">
                        <span style="padding-right: 20px;color: #57a0ff;font-weight:700;font-size: 14px" class="addTable">添加</span>
                        <img src="<%=path%>/image/delete212.png" class="deleteTable">
                        <span class="deleteTable" style="color: #57a0ff;font-weight:700;font-size: 14px" class="deleteTable">删除</span>
                    </div>
                </div>
                <div style="overflow:auto;/* min-height: 200px; */width: 88%; height:250px;margin-left: 90px">
                    <table id="table1" style="min-height:50px;border-spacing:0;width: auto;white-space:nowrap;">
                        <tr  class="tr">
                        	<td><%--<input type="checkbox" name="check" value="" class="check1">--%></td>
                            <td >序号</td>
                            <td style="width: 90px;" align="center">准考证明编号</td>
                            <td style="width: 90px;" align="center">学员姓名</td>
                            <td style="width: 90px;" align="center">学员编码</td>
                            <td style="width: 90px;" align="center">身份证号</td>
                            <td style="width: 90px;" align="center">性别</td>
                            <td style="width: 90px;" align="center">手机号码</td>
                            <td style="width: 90px;" align="center">电话</td>
                            <td style="width: 90px;" align="center">推荐人</td>
                            <td style="width: 90px;" align="center">申请准驾车型代号</td>
                            <td style="width: 90px;" align="center">本地/异地</td>
                            <td style="width: 90px;" align="center">考试次数</td>
                            <td style="width: 90px;" align="center">初考/补考</td>
                            <td style="width: 90px;" align="center">本校/外校</td>
                            <td style="width: 90px;" align="center">班级</td>
                            <td style="width: 90px;" align="center">已收</td>
                            <td style="width: 90px;" align="center">优惠</td>
                            <td style="width: 90px;" align="center">应收</td>
                            <td style="width: 90px;" align="center">欠费</td>
                            <td style="width: 90px;" align="center">备注</td>
                            <td style="width: 90px;" align="center">档案交接</td>
                            <td style="width: 90px;" align="center">技能表交接</td>                        
                        </tr>
                    </table>
                </div>

                <div style="margin-top: 10px; margin-left: 90px;">已退学员</div>
                <div class="div_zilei">
                    <%--<div style="width: 88%;text-align: right;">
                        <img src="<%=path%>/image/insert2323.jpg" class="addTable">
                        <span style="padding-right: 20px;color: #a9bbe0;font-size: 14px" class="addTable">添加</span>
                        <img src="<%=path%>/image/delete212.png" class="deleteTable">
                        <span class="deleteTable" style="color: #a9bbe0;font-size: 14px" class="deleteTable">删除</span>
                    </div>--%>
                </div>
                <div style="overflow:auto;min-height: 200px;width: 88%;margin-left: 90px">
                    <table id="table2" style="min-height:50px;border-spacing:0;width: auto;white-space:nowrap;">
                        <tr class="tr">
                            <td><%--<input type="checkbox" name="check" value="" >--%></td>
                            <td >序号</td>
                            <td style="width: 90px;" align="center">准考证明编号</td>
                            <td style="width: 90px;" align="center">学员姓名</td>
                            <td style="width: 90px;" align="center">学员编码</td>
                            <td style="width: 90px;" align="center">身份证号</td>
                            <td style="width: 90px;" align="center">性别</td>
                            <td style="width: 90px;" align="center">手机号码</td>
                            <td style="width: 90px;" align="center">电话</td>
                            <td style="width: 90px;" align="center">推荐人</td>
                            <td style="width: 90px;" align="center">申请准驾车型代号</td>
                            <td style="width: 90px;" align="center">本地/异地</td>
                            <td style="width: 90px;" align="center">考试次数</td>
                            <td style="width: 90px;" align="center">初考/补考</td>
                            <td style="width: 90px;" align="center">本校/外校</td>
                            <td style="width: 90px;" align="center">班级</td>                          
                            <td style="width: 90px;" align="center">备注</td>
                            <td style="width: 90px;" align="center">档案交接</td>
                            <td style="width: 90px;" align="center">技能表交接</td>   
                        </tr>                      
                    </table>
                </div>
				<%--<div class="div_input_hang">
                    
                </div>--%>
                <div class="div_input_hang">
                    <div class="input_hang">
                        <span class="gn_name">审核人&nbsp;:&nbsp;</span>
                        <input name="checkName" style="color: gray;" readonly="readonly"/>
                    </div>
                    <div class="input_hang">
                        <span class="gn_name">创建者&nbsp;:&nbsp;</span>
                        <input name="createName" style="color: gray;" value="${user.name }" readonly="readonly"/>
                        
                    </div>
                    <div class="input_hang">
                        <span class="gn_name">创建时间&nbsp;:&nbsp;</span>
                        <input name="fcreatetime"  style="color: gray;" readonly="readonly" value="${createTime }"/>
                    </div>
                </div>

                <div class="div_tj" style="padding-top: 0px;margin-top: 10px;margin-left: 140px;">
                    <div>
                        <input  class="input_submit bc" value="" type="submit" style="margin-top: 0px;margin-right: 30px;">
                    </div>
                    <div>
                        <input type="button" class="input_back fh" value="" onclick="back()" style="margin-top: 0px;"/>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="<%=path%>/JQuery/jquery-1.8.2.js"></script>
<%@ include file="/WEB-INF/JSP/ajax.jsp" %>
<script type="text/javascript" src="<%=path%>/HoganJS/handlebars-v4.0.11.js"></script>
<script id="table-template1-sub" type="text/x-handlebars-template">
    {{#each studentsNameList}}
	<tr class="tr_td">
		<td><input type="checkbox" name="checkchilden" value="">
			<input type="hidden" class="subfid" name="subfid" value="{{fid}}" readonly="readonly">
			<input type="hidden" class="subcfclazzid" name="subcfclazzid" value="{{cfclazzid}}" readonly="readonly">
		</td>
 		<td><input type="text" class="fseq1" name="subfseq" value="" readonly="readonly">			
		</td>       
        <td align="center"><input class="cfzkzmbh" style="width: 90px;" type="text" name="subcfzkzmbh" value="{{cfzkzmbh}}" readonly="readonly"/></td>
        <td align="center"><input style="width: 90px;" type="text" name="subfnameL2" value="{{fnameL2}}" class="clickName is_click_ne" readonly="readonly"/></td>
        <td align="center"><input style="width: 170px;" type="text" name="subfnumber" value="{{fnumber}}" readonly="readonly"/></td>
		<td align="center"><input style="width: 140px;" type="text"  name="subcfidcardno" value="{{cfidcardno}}" readonly="readonly"/></td>
		{{#compare cfsex 1}}
			<td align="center"><input style="width: 90px;" type="text" name="subcfsex" value="男" readonly="readonly"/></td>
		 {{else}}
        	<td align="center"><input style="width: 90px;" type="text" name="subcfsex" value="女" readonly="readonly"/></td>
		{{/compare}}        
        <td align="center"><input style="width: 90px;" type="text" name="subcfsjhm" value="{{cfsjhm}}" readonly="readonly"/></td>
        <td align="center"><input style="width: 90px;" type="text" name="subcflxdh" value="{{cflxdh}}" readonly="readonly"/></td>
        <td align="center"><input style="width: 90px;" type="text" name="subcftjrName" value="{{cftjrName}}" readonly="readonly"/>
			<input style="width: 90px;" type="hidden" name="subcftjrid" value="{{cftjrid}}" readonly="readonly"/>
		</td>
        <td align="center"><input style="width: 90px;" type="text" name="subcfslzjcxdh" value="{{cfslzjcxdh}}" readonly="readonly"/></td>
		{{#compare cflocal 1}}		
        <td align="center"><input style="width: 90px;" type="text" name="subcflocal" value="本地" readonly="readonly"/></td>
		{{/compare}}
		{{#compare cflocal 2}}		
        <td align="center"><input style="width: 90px;" type="text" name="subcflocal" value="异地" readonly="readonly"/></td>
		{{/compare}}
		{{#compare cflocal 3}}		
        <td align="center"><input style="width: 90px;" type="text" name="subcflocal" value="学生" readonly="readonly"/></td>
		{{/compare}}
		{{#compare cfkmykss null}}
        <td align="center"><input style="width: 90px;" type="text" name="subcfkmykss" value="0" readonly="readonly"/></td>
		{{else}}
		 <td align="center"><input style="width: 90px;" type="text" name="subcfkmykss" value="{{cfkmykss}}" readonly="readonly"/></td>
		{{/compare}}
		{{#compare cfkmykss 0}}
			<td align="center"><input style="width: 90px;" type="text" name="subcfckbk" value="初考" readonly="readonly"/></td>
		{{else}}
        	<td align="center"><input style="width: 90px;" type="text" name="subcfckbk" value="补考" readonly="readonly"/></td>
		{{/compare}}
		{{#compare cfbxwx 1}}
        <td align="center"><input style="width: 90px;" type="text" name="subcfbxwx" value="本校" readonly="readonly"/></td>
		{{else}}
		 <td align="center"><input style="width: 90px;" type="text" name="subcfbxwx" value="外校" readonly="readonly"/></td>
		{{/compare}}
        <td align="center"><input style="width: 150px;" type="text" name="subcfclazzName" value="{{cfclazzName}}" readonly="readonly"/></td>
        <td align="center"><input style="width: 90px;" type="text" name="subcfreceived" value="{{cfreceived}}" readonly="readonly"/></td>
		{{#compare cffavorable null}}
        <td align="center"><input style="width: 90px;" type="text" name="subcffavorable" value="0" readonly="readonly"/></td>
		{{else}}
		<td align="center"><input style="width: 90px;" type="text" name="subcffavorable" value="{{cffavorable}}" readonly="readonly"/></td>
		{{/compare}}      
        <td align="center"><input style="width: 90px;" type="text" name="subcfamount" value="{{cfamount}}" readonly="readonly"/></td>
        <td align="center"><input style="width: 90px;" type="text" name="subcfarrearage" value="{{cfarrearage}}" readonly="readonly"/></td>
        <td align="center"><input style="width: 140px;" type="text" name="cfremark" value="{{cfremark}}"/></td>
		{{#compare cfdajj null}}
        	<td align="center"><input style="width: 90px;" type="checkbox"  disabled="disabled" readonly="readonly" name="subcfdajj" value="{{cfdajj}}"/></td>
		{{/compare}}
		{{#compare cfdajj 0}}
        	<td align="center"><input style="width: 90px;" type="checkbox"  disabled="disabled" readonly="readonly" name="subcfdajj" value="{{cfdajj}}"/></td>
		{{/compare}}		
		{{#compare cfdajj 1}}
			<td align="center"><input style="width: 90px;" type="checkbox" checked="checked" disabled="disabled" readonly="readonly" name="subcfdajj" value="{{cfdajj}}"/></td>
		{{/compare}}
		{{#compare cfjnbjj null}}
        	<td align="center"><input style="width: 90px;" type="checkbox" disabled="disabled" readonly="readonly" name="subcfjnbjj" value="{{cfjnbjj}}"/></td>
		{{/compare}}
		{{#compare cfjnbjj 0}}
        	<td align="center"><input style="width: 90px;" type="checkbox" disabled="disabled" readonly="readonly" name="subcfjnbjj" value="{{cfjnbjj}}"/></td>
		{{/compare}}
		{{#compare cfjnbjj 1}}
			<td align="center"><input style="width: 90px;" type="checkbox" checked="checked" disabled="disabled" readonly="readonly" name="subcfjnbjj" value="{{cfjnbjj}}"/></td>
		{{/compare}}       
    </tr>
	{{/each}}
</script>

<script id="table-template2-sub" type="text/x-handlebars-template">
    {{#each this}}
	<tr class="tr_td">
		<td><input type="checkbox" name="checkchilden" value="">
			<input type="hidden" class="subfid" name="subfid" value="{{cfstudentid}}" readonly="readonly">
			<input type="hidden" class="subcfclazzid" name="subcfclazzid" value="{{cfclazzid}}" readonly="readonly">
		</td>
 		<td><input type="text" class="fseq1" name="subfseq" value="" readonly="readonly">			
		</td>       
        <td align="center"><input class="cfzkzmbh" style="width: 90px;" type="text" name="subcfzkzmbh" value="{{cfzkzmbh}}" readonly="readonly"/></td>
        <td align="center"><input style="width: 90px;" type="text" name="subfnameL2" value="{{cfstudentname}}" class="clickName is_click_ne" readonly="readonly"/></td>
        <td align="center"><input style="width: 170px;" type="text" name="subfnumber" value="{{stufnumber}}" readonly="readonly"/></td>
		<td align="center"><input style="width: 140px;" type="text" name="subcfidcardno" value="{{cfidcardno}}" readonly="readonly"/></td>
		{{#compare cfsex 1}}
			<td align="center"><input style="width: 90px;" type="text" name="subcfsex" value="男" readonly="readonly"/></td>
		 {{else}}
        	<td align="center"><input style="width: 90px;" type="text" name="subcfsex" value="女" readonly="readonly"/></td>
		{{/compare}}        
        <td align="center"><input style="width: 90px;" type="text" name="subcfsjhm" value="{{cfmobile}}" readonly="readonly"/></td>
        <td align="center"><input style="width: 90px;" type="text" name="subcflxdh" value="{{cfphone}}" readonly="readonly"/></td>
        <td align="center"><input style="width: 90px;" type="text" name="subcftjrName" value="{{cftjr}}" readonly="readonly"/>
			<input style="width: 90px;" type="hidden" name="subcftjrid" value="{{cftjrid}}" readonly="readonly"/>
		</td>
        <td align="center"><input style="width: 90px;" type="text" name="subcfslzjcxdh" value="{{cfsqzjcxdh}}" readonly="readonly"/></td>
		{{#compare cfbdyd 1}}
        <td align="center"><input style="width: 90px;" type="text" name="subcflocal" value="本地" readonly="readonly"/></td>
		{{/compare}}
		{{#compare cfbdyd 2}}
        <td align="center"><input style="width: 90px;" type="text" name="subcflocal" value="异地" readonly="readonly"/></td>
		{{/compare}}
		{{#compare cfbdyd 3}}
        <td align="center"><input style="width: 90px;" type="text" name="subcflocal" value="学生" readonly="readonly"/></td>
		{{/compare}}
        {{#compare cfkmykss null}}
        <td align="center"><input style="width: 90px;" type="text" name="subcfkmykss" value="0" readonly="readonly"/></td>
		{{else}}
		 <td align="center"><input style="width: 90px;" type="text" name="subcfkmykss" value="{{cfkmykss}}" readonly="readonly"/></td>
		{{/compare}}
		{{#compare cfkmykss 0}}
			<td align="center"><input style="width: 90px;" type="text" name="subcfckbk" value="初考" readonly="readonly"/></td>
		{{else}}
        	<td align="center"><input style="width: 90px;" type="text" name="subcfckbk" value="补考" readonly="readonly"/></td>
		{{/compare}}
		{{#compare cfbxwx 1}}
        <td align="center"><input style="width: 90px;" type="text" name="subcfbxwx" value="本校" readonly="readonly"/></td>
		{{else}}
		 <td align="center"><input style="width: 90px;" type="text" name="subcfbxwx" value="外校" readonly="readonly"/></td>
		{{/compare}}
        <td align="center"><input style="width: 150px;" type="text" name="subcfclazzName" value="{{clazzname}}" readonly="readonly"/></td>
        <td align="center"><input style="width: 90px;" type="text" name="subcfreceived" value="{{cfreceived}}" readonly="readonly"/></td>
        {{#compare cffavorable null}}
        <td align="center"><input style="width: 90px;" type="text" name="subcffavorable" value="0" readonly="readonly"/></td>
		{{else}}
		<td align="center"><input style="width: 90px;" type="text" name="subcffavorable" value="{{cffavorable}}" readonly="readonly"/></td>
		{{/compare}}            
        <td align="center"><input style="width: 90px;" type="text" name="subcfamount" value="{{cfamount}}" readonly="readonly"/></td>
        <td align="center"><input style="width: 90px;" type="text" name="subcfarrearage" value="{{cfarrearage}}" readonly="readonly"/></td>
        <td align="center"><input style="width: 140px;" type="text" name="cfremark" value="{{cfremark}}" /></td>
		{{#compare cfdajj 0}}
        	<td align="center"><input style="width: 90px;" type="checkbox"  disabled="disabled" readonly="readonly" name="subcfdajj" value="0"/></td>
		{{/compare}}
		{{#compare cfdajj null}}
        	<td align="center"><input style="width: 90px;" type="checkbox"  disabled="disabled" readonly="readonly" name="subcfdajj" value="0"/></td>
		{{/compare}}
		{{#compare cfdajj 1}}
			<td align="center"><input style="width: 90px;" type="checkbox" checked="checked" disabled="disabled" readonly="readonly" name="subcfdajj" value="1"/></td>
		{{/compare}}

		{{#compare cfjnbjj 0}}
        	<td align="center"><input style="width: 90px;" type="checkbox" disabled="disabled" readonly="readonly" name="subcfjnbjj" value="0"/></td>
		{{/compare}}
		{{#compare cfjnbjj null}}
        	<td align="center"><input style="width: 90px;" type="checkbox" disabled="disabled" readonly="readonly" name="subcfjnbjj" value="0"/></td>
		{{/compare}}
		{{#compare cfjnbjj 1}} 
			<td align="center"><input style="width: 90px;" type="checkbox" checked="checked" disabled="disabled" readonly="readonly" name="subcfjnbjj" value="1"/></td>
		{{/compare}}       
    </tr>
	{{/each}}
</script>

<script id="table-template3-sub" type="text/x-handlebars-template">
    {{#each studentsNameList}}
		<td><input type="checkbox" name="checkchilden" value="">
			<input type="hidden" class="subfid" name="subfid" value="{{fid}}" readonly="readonly">
			<input type="hidden" class="subcfclazzid" name="subcfclazzid" value="{{cfclazzid}}" readonly="readonly">
		</td>
 		<td><input type="text" class="fseq1" name="subfseq" value="" readonly="readonly">			
		</td>       
        <td align="center"><input class="cfzkzmbh" style="width: 90px;" type="text" name="subcfzkzmbh" value="{{cfzkzmbh}}" readonly="readonly"/></td>
        <td align="center"><input style="width: 90px;" type="text" name="subfnameL2" value="{{fnameL2}}" class="clickName is_click_ne" readonly="readonly"/></td>
        <td align="center"><input style="width: 170px;" type="text" name="subfnumber" value="{{fnumber}}" readonly="readonly"/></td>
		<td align="center"><input style="width: 140px;" type="text" name="subcfidcardno" value="{{cfidcardno}}" readonly="readonly"/></td>
		{{#compare cfsex 1}}
			<td align="center"><input style="width: 90px;" type="text" name="subcfsex" value="男" readonly="readonly"/></td>
		 {{else}}
        	<td align="center"><input style="width: 90px;" type="text" name="subcfsex" value="女" readonly="readonly"/></td>
		{{/compare}}        
        <td align="center"><input style="width: 90px;" type="text" name="subcfsjhm" value="{{cfsjhm}}" readonly="readonly"/></td>
        <td align="center"><input style="width: 90px;" type="text" name="subcflxdh" value="{{cflxdh}}" readonly="readonly"/></td>
        <td align="center"><input style="width: 90px;" type="text" name="subcftjrName" value="{{cftjrName}}" readonly="readonly"/>
			<input style="width: 90px;" type="hidden" name="subcftjrid" value="{{cftjrid}}" readonly="readonly"/>
		</td>
        <td align="center"><input style="width: 90px;" type="text" name="subcfslzjcxdh" value="{{cfslzjcxdh}}" readonly="readonly"/></td>
		{{#compare cflocal 1}}		
        <td align="center"><input style="width: 90px;" type="text" name="subcflocal" value="本地" readonly="readonly"/></td>
		{{/compare}}
		{{#compare cflocal 2}}		
        <td align="center"><input style="width: 90px;" type="text" name="subcflocal" value="异地" readonly="readonly"/></td>
		{{/compare}}
		{{#compare cflocal 3}}		
        <td align="center"><input style="width: 90px;" type="text" name="subcflocal" value="学生" readonly="readonly"/></td>
		{{/compare}}
        {{#compare cfkmykss null}}
        <td align="center"><input style="width: 90px;" type="text" name="subcfkmykss" value="0" readonly="readonly"/></td>
		{{else}}
		 <td align="center"><input style="width: 90px;" type="text" name="subcfkmykss" value="{{cfkmykss}}" readonly="readonly"/></td>
		{{/compare}}
		{{#compare cfkmykss 0}}
			<td align="center"><input style="width: 90px;" type="text" name="subcfckbk" value="初考" readonly="readonly"/></td>
		{{else}}
        	<td align="center"><input style="width: 90px;" type="text" name="subcfckbk" value="补考" readonly="readonly"/></td>
		{{/compare}}
		{{#compare cfbxwx 1}}
        <td align="center"><input style="width: 90px;" type="text" name="subcfbxwx" value="本校" readonly="readonly"/></td>
		{{else}}
		 <td align="center"><input style="width: 90px;" type="text" name="subcfbxwx" value="外校" readonly="readonly"/></td>
		{{/compare}}
        <td align="center"><input style="width: 150px;" type="text" name="subcfclazzName" value="{{cfclazzName}}" readonly="readonly"/></td>
        <td align="center"><input style="width: 90px;" type="text" name="subcfreceived" value="{{cfreceived}}" readonly="readonly"/></td>
        {{#compare cffavorable null}}
        <td align="center"><input style="width: 90px;" type="text" name="subcffavorable" value="0" readonly="readonly"/></td>
		{{else}}
		<td align="center"><input style="width: 90px;" type="text" name="subcffavorable" value="{{cffavorable}}" readonly="readonly"/></td>
		{{/compare}}            
        <td align="center"><input style="width: 90px;" type="text" name="subcfamount" value="{{cfamount}}" readonly="readonly"/></td>
        <td align="center"><input style="width: 90px;" type="text" name="subcfarrearage" value="{{cfarrearage}}" readonly="readonly"/></td>
        <td align="center"><input style="width: 140px;" type="text" name="cfremark" value="{{cfremark}}"/></td>
		{{#compare cfdajj null}}
        	<td align="center"><input style="width: 90px;" type="checkbox"  disabled="disabled" readonly="readonly" name="subcfdajj" value="{{cfdajj}}"/></td>
		{{/compare}}
		{{#compare cfdajj 0}}
        	<td align="center"><input style="width: 90px;" type="checkbox"  disabled="disabled" readonly="readonly" name="subcfdajj" value="{{cfdajj}}"/></td>
		{{/compare}}		
		{{#compare cfdajj 1}}
			<td align="center"><input style="width: 90px;" type="checkbox" checked="checked" disabled="disabled" readonly="readonly" name="subcfdajj" value="{{cfdajj}}"/></td>
		{{/compare}}
		{{#compare cfjnbjj null}}
        	<td align="center"><input style="width: 90px;" type="checkbox" disabled="disabled" readonly="readonly" name="subcfjnbjj" value="{{cfjnbjj}}"/></td>
		{{/compare}}
		{{#compare cfjnbjj 0}}
        	<td align="center"><input style="width: 90px;" type="checkbox" disabled="disabled" readonly="readonly" name="subcfjnbjj" value="{{cfjnbjj}}"/></td>
		{{/compare}}
		{{#compare cfjnbjj 1}}
			<td align="center"><input style="width: 90px;" type="checkbox" checked="checked" disabled="disabled" readonly="readonly" name="subcfjnbjj" value="{{cfjnbjj}}"/></td>
		{{/compare}}         
	{{/each}}
</script>
<script type="text/javascript">
    $(document).ready(function(){
        var type = "${type}";
        if(type == '0' || type == '' || type == null) {

        }else{
            //alert("添加成功");
            editAlert();
        }
    })

  	//处理修改时候的this缓存
    var _this=null;
    //判断当前操作使增加还是删除
    var num = 0;//当前报名的人数
    num=Number(num)

	//注册一个比较大小的Helper,判断v1是否大于v2
	Handlebars.registerHelper("compare", function (v1, v2, options) {
   	 	if (v1 == v2) {
       	 	//满足添加继续执行
        	return options.fn(this);
    	} else {
        	//不满足条件执行{{else}}部分
        	return options.inverse(this);
    	}
	});

    //已报学员
    var myTemplate1 = Handlebars.compile($("#table-template1-sub").html());
    //已经预约学员
    var myTemplate2 = Handlebars.compile($("#table-template2-sub").html());
    //修改
    var myTemplate3 = Handlebars.compile($("#table-template3-sub").html()); 
    //删除一行
    $(".deleteTable").click(function () {
    	var k = 0;
    	$("input:checkbox[name=checkchilden]:checked").each(function(i){  		
    		k++;
    	})
    	if(k == 0){
    		alert("请选中需要删除的行!")
    		return false;
    	}
    	$("input:checkbox[name=checkchilden]:checked").each(function(i){
    		$(this).parent().parent().remove()   		
    	})
    	num=num-k;
    	$("#cfdqbkrs").val(num)//当前报考数
        $("#cfzbs").val(num)//指标数
      	//处理序号
		$("input:text[name=subfseq]").each(function(i){  					
		    $(this).val(i+1);
		})  
    })
    $('.addTable').click(function () {
    	var examdate=$("#ywrq").val();//获取考试日期
    	if(examdate == null || examdate == ''){
    		alert("请选择考试日期！")
    		$("#ywrq").focus()
    	}else{
    		getPagExamSub()
    		//$('#table1').html($('#table1').html());
       	    $('#modal-overlay').css('visibility', 'visible')
            $('.modal-data').css('visibility', 'visible')
            $('input:checkbox[name=student]').removeAttr('checked');
            $('.page').show();
    	}
         
    })
    
     //查找符合预约过科目一考试的学员
    function getPagExamSub(){
    	var examdate=$("#ywrq").val().trim()//考试日期
    	var carType=$(".cfcartype").val();//获取车型
    	var subjectType=$("#subjectType").val();//获取考试细腻==
        myname = $('.name1').val();
        cflxdh = $('.cflxdh').val();
        $('#studebntList').html("<div class='loading'></div>");
        $.ajax({
            url: '<%=path2%>/DrivingSys/getPagExamSub?pindex=0&name=' + myname + '&cflxdh=' + cflxdh + '&beginTime=' + beginTime.val() + '&endTime=' + endTime.val()+'&examdate='+examdate+'&carType='+carType+'&subjectType='+subjectType,
            type: "get",
            dataType: "json",
            success: function (res) {
                $('#studebntList').html(myTemplate(res));
                $('#totalPage').val(res.pb);
            },
            error: function () {
                alert('Error');
            }
        });        
    }



    /* 关闭弹出框    */
    $('.btn').click(function () {
        $('#modal-overlay').css('visibility', 'hidden')
        $('.modal-data1').css('visibility', 'hidden')
        $('.modal-data').css('visibility', 'hidden')
        $('input:checkbox[name=student]').removeAttr('checked');
        $('.page').hide();
        _this = null;
    })



    //弹出模式框
    $('.clickName').live('click',function(){
        getPagExamSub();
        $('#modal-overlay').css('visibility', 'visible')
        $('.modal-data').css('visibility', 'visible')
        $('input:checkbox[name=student]').removeAttr('checked');
        $('.page').show();
        _this = $(this).parent().parent();
    })


	
    //双击确认
    $(document).on('dblclick','.xysj td',function(){
    	var id ="";
    	var j = 1;
    	id = $(this).parent().find("td:nth-child(1)").find("input").val()    	
    	selStudentMesg(j,id); 
    	
    })
    
    //把选中的信息名称填充到输入框中
    $('.subtn').click(function () {
        var spCodesTemp = "";
        var j=0;
        $('input:checkbox[name=student]:checked').each(function (i) {
        	j+=1
            if (0 == i) {
                //把学生id增加到字表中
                spCodesTemp = $(this).val();

            } else {
                spCodesTemp += ("," + $(this).val());

            }
        });
        if(spCodesTemp == ''){
        	alert("至少勾选一项!")
        	return false;
        }
        if(_this != null){
        	 $('input:checkbox[name=student]:checked').each(function (i) {
             	j+=1
                 if (0 == i) {
                     //把学生id增加到字表中
                     spCodesTemp = $(this).val();
                 } 
             });
        }
        selStudentMesg(j,spCodesTemp);      
    });
    
   function selStudentMesg(j,ids){
       var ary_new=new Array();
       ary_new=ids.split(",");
       //获取已经在列表的学员id
       var students = "";
           for(var j =0;j<ary_new.length;j++){
               $(".subfid").each(function(i) {
                   if ($(this).val() == ary_new[j]) {
                       var name = $(this).parent().parent().find("td input[name=subfnameL2]").val();
                       if (j == 0) {
                           students = name;
                       } else {
                           students += "," + name;
                       }
                   }
               })
           }
       if(students != ''){
           alert(students+" 已经在列表中,请重新选择学员!")
           return false;
       }
	   $.ajax({
           url: '<%=path%>/DrivingSys/selStudentsByFid',
           type: "post",
           data: {'id': ids},
           dataType: "json",
           success: function (res) {
           	var htmlhead = "<tr class='tr'> <td class='fseq'>序号</td> <td align='center'>准考证明编号</td><td align='center'>学员姓名</td><td align='center'>身份证号码</td> <td align='center'>性别</td> <td align='center'>手机号码</td> <td align='center'>电话</td>"  
           	htmlhead+="<td align='center'>推荐人</td><td align='center'>申请准驾车型代号</td><td align='center'>本地/异地</td><td align='center'>考试次数</td><td align='center'>初考/补考</td>"
           	htmlhead+="<td align='center'>本校/外校</td><td align='center'>班级</td><td align='center'>已收</td><td align='center'>优惠</td><td align='center'>应收</td><td align='center'>欠费</td><td align='center'>备注</td><td align='center'>档案交接</td><td align='center'>技能表交接</td></tr>"           
           	var htmlhead1 = $('#table1').html();
           	if(_this != null){          		
           		_this.html(myTemplate3(res))
                _this = null;
           	}else{
           		$('#table1').html(htmlhead1+myTemplate1(res));
           	 	num+=j
             	j=0;
             	$("#cfdqbkrs").val(num)
             	$("#cfzbs").val(num)
           	}
               $('#modal-overlay').css('visibility', 'hidden')
               $('.modal-data').css('visibility', 'hidden')
               //处理序号
			   $("input:text[name=subfseq]").each(function(i){  					
  			   		$(this).val(i+1); 		  
			   })             
           },
           error: function () {
               alert('Error');
           }
       });   
   }

    //添加预约科目一的学员
    $('.addSubscribeStudent').click(function () {
        var fbizdate = $("#ywrq").val();
        var carType = $(".cfcartype").val()
        if (fbizdate == null || fbizdate == '') {
            alert("考试日期不能为空！")
            $("#ywrq").focus()
        } else {
            $.ajax({
                url: '<%=path%>/DrivingSys/selExamsubscribeByFbizdate',
                type: "post",
                data: {'fbizdate': fbizdate, 'carType': carType},
                dataType: "json",
                success: function (json) {
                    if (json == null || json == '') {
                        alert("抱歉，该天没有预约科目一车型为" + carType + "的学员！")
                    } else {
                        var students = "";
                        var count = 0;//计数
                        var item = new Array();//记录重复学员对象的下标
                        for (var j = 0; j < json.length; j++) {
                            $(".subfid").each(function (i) {
                                if ($(this).val() == json[j].cfstudentid) {
                                    item.push(j)
                                    var name = $(this).parent().parent().find("td input[name=subfnameL2]").val();
                                    if (count == 0) {
                                        students = name;
                                    } else {
                                        students += "," + name;
                                    }
                                    count++;
                                }
                            })
                        }
                        if (students != '') {
                            for (var k = 0;k<item.length;k++){
                                delete (json[item[k]]);//删除重复的学员对象
;                            }
                            alert(students + " 已经在列表中,请重新选择学员!")
                            //return false;
                        }
                        var htmlhead2 = $('#table1').html();
                        $('#table1').html(htmlhead2 + myTemplate2(json));
                        num += json.length-item.length
                        //alert(num)
                        $("#cfdqbkrs").val(num)
                        $("#cfzbs").val(num)
                        //处理序号
                        $("input:text[name=subfseq]").each(function (i) {
                            $(this).val(i + 1);
                        })
                    }
                },
                error: function () {
                    alert('Error');
                }
            });
        }
    });
  //设置全选功选 
	$('.check1').live('click',function(){		
		if($(this).attr("checked")){
			 $('input:checkbox[name=checkchilden]').attr("checked",":checked") 
		}else{			
			 $('input:checkbox[name=checkchilden]').removeAttr('checked');
		}
	})

   //由于和input:checkbox冲突，在选择一次
 $("#table1 tr td input:checkbox:not(.check1)").live('click',function(){
	  if($(this).is(':checked')){
	    	$(this).removeAttr("checked");
	    }else{
	    	$(this).attr("checked",":checked")
	    } 
 }) 
  //单击选中
  $("#table1 tr td").live('click',function(){
    if($(this).parent().find("input:checkbox[name=checkchilden]").is(':checked')){
    	$(this).parent().find("input:checkbox[name=checkchilden]").removeAttr("checked");
    }else{
    	$(this).parent().find("input:checkbox[name=checkchilden]").attr("checked",":checked")
    }
 }) 
  //返回
	function back(){
        parent.closeSelectCard()

        //location = '<%=path%>/DrivingSys/querySubjectOneReg/look.action';
	}
	function subForm(){
	    var count =0;
	    $("input:checkbox[name=checkchilden]").each(function(i){
	        count ++;
        })
        if(count == 0){
	        alert("请先添加学员!")
	        return false;
        }
        $("input[type='submit']").attr("disabled", "disabled");
    }
    //改变业务日期或者车型清空已经增加的学员
    var oldTime =$("#ywrq").val();//记录改变之前的时间
    function changeFbizdate(obj) {
        if(oldTime  == '' ){
            oldTime = $("#ywrq").val()
        }
        var k = 0;
        $("input:checkbox[name=checkchilden]").each(function(i){
            k++;
        })
        if(k != 0){
            $.messager.confirm('提示', '考试时间或者车型改变，将清空之前录入的学员数据!', function (r) {
                if (r) {
                    $("input:checkbox[name=checkchilden]").each(function (i) {
                        $(this).parent().parent().remove()
                    })
                    num = num - k;
                    $("#cfdqbkrs").val(num)
                    $("#cfzbs").val(num)
                    oldTime = $("#ywrq").val()
                } else {
                    $("#ywrq").val(oldTime)
                }
            })
        }else{//把oldTime赋值
            oldTime = $("#ywrq").val()
        }
    }
    var oldCartype = $(".cfcartype").val();//记录之前的车型
    function changeCartype() {
        var k = 0;
        $("input:checkbox[name=checkchilden]").each(function(i){
            k++;
        })
        if(k != 0){
            $.messager.confirm('提示', '考试时间或者车型改变，将清空之前录入的学员数据!', function (r) {
                if (r) {
                    $("input:checkbox[name=checkchilden]").each(function (i) {
                        $(this).parent().parent().remove()
                    })
                    num = num - k;
                    $("#cfdqbkrs").val(num)
                    $("#cfzbs").val(num)
                    oldCartype = $(".cfcartype").val()
                } else {
                    $(".cfcartype").val(oldCartype)
                }
            })
        }else{//把oldTime赋值
            oldCartype = $(".cfcartype").val()
        }
    }
</script>
</html>